﻿Imports Microsoft.VisualBasic

Public Class sql_str_Class

    Private Shared sql_str_section As String() = New String() {
       "SELECT id, sort as str_key FROM books Order By sort",
       "SELECT id, name  as str_key FROM authors Order By sort",
       "SELECT DISTINCT format as id, format as str_key FROM data Order By format",
       "SELECT DISTINCT type as id, type as str_key FROM identifiers Order By type",
       "SELECT DISTINCT lang_code as id, lang_code as str_key FROM languages Order By lang_code",
       "SELECT id, name as str_key FROM publishers Order By sort",
       "SELECT DISTINCT rating as id, rating as str_key FROM ratings Order By rating",
       "SELECT id, name as str_key FROM series Order By sort",
       "SELECT id, name as str_key FROM tags Order By name"
   }

    Private Shared sql_str_where As String() = New String() {
       "WHERE (books.sort LIKE  '{0}%')",
       "INNER JOIN authors ON books_authors_link.author = authors.id INNER JOIN books_authors_link ON books.id = books_authors_link.book WHERE (authors.id = '{0}')",
       "INNER JOIN data ON books.id = data.book WHERE (data.format = '{0}')",
       "INNER JOIN identifiers ON books.id = identifiers.book WHERE (identifiers.type = '{0}')",
       "INNER JOIN languages ON books_languages_link.lang_code = languages.id INNER JOIN books_languages_link ON books.id = books_languages_link.book WHERE (languages.lang_code = '{0}')",
       "INNER JOIN publishers ON books_publishers_link.publisher = publishers.id INNER JOIN books_publishers_link ON books.id = books_publishers_link.book WHERE (publishers.id = '{0}')",
       "INNER JOIN ratings ON books_ratings_link.rating = ratings.id INNER JOIN books_ratings_link ON books_ratings_link.book = books.id WHERE (ratings.rating = '{0}')",
       "INNER JOIN series ON books_series_link.series = series.id INNER JOIN books_series_link ON books.id = books_series_link.book WHERE (series.id = '{0}')",
       "INNER JOIN tags ON books_tags_link.tag = tags.id INNER JOIN books_tags_link ON books.id = books_tags_link.book WHERE (tags.id = '{0}')"
    }

    Private Shared sql_str_key As String() = New String() {
        "sort",
        "name",
        "format",
        "type",
        "lang_code",
        "name",
        "rating",
        "name",
        "name"
    }

    Private Shared sql_str_tables As String() = New String() {
        "books",
        "authors",
        "data",
        "identifiers",
        "languages",
        "publishers",
        "ratings",
        "series",
        "tags"
    }

    Private Shared sql_str_keyid As String() = New String() {
"id",
"id",
"format",
"type",
"lang_code",
"id",
"rating",
"id",
"id"
}

    Public Property NameArray() As String()
        Get
            Return sql_str_section
        End Get
        Set(ByVal value As String())
            sql_str_section = value
        End Set
    End Property

    Public Shared Function Get_sql_str_section() As String()
        Return sql_str_section
    End Function
    Public Shared Function Get_sql_str_where() As String()
        Return sql_str_where
    End Function
    Public Shared Function Get_sql_str_key() As String()
        Return sql_str_key
    End Function
    Public Shared Function Get_sql_str_tables() As String()
        Return sql_str_tables
    End Function
    Public Shared Function Get_sql_str_keyid() As String()
        Return sql_str_keyid
    End Function

End Class



